"""
行为树黑板: 存储class对象, dist,list复杂对象
"""

import py_trees


class Student:
    def __init__(self):
        self.name: str = ""
        self.age: int = 0

    def __str__(self):
        return str(self.__dict__)


if __name__ == "__main__":
    blackboard = py_trees.blackboard.Client(name="Writer")

    # 1.存储class对象
    blackboard.register_key("student", access=py_trees.common.Access.WRITE)
    blackboard.student = Student()
    blackboard.student.name = "Tom"
    blackboard.student.age = 18
    print(blackboard.student)

    # 2.存储dist,list复杂对象
    blackboard.register_key("list", access=py_trees.common.Access.WRITE)
    blackboard.list = [1, 2, 3]
    print(blackboard.list)

""" 输出:
{'name': 'Tom', 'age': 18}
[1, 2, 3]
"""